local skel = fk.CreateSkill {
  name = "lb__yingchi",
  tags = { Skill.Compulsory }
}

Fk:loadTranslationTable {
  ["lb__yingchi"] = "影翅",
  [":lb__yingchi"] = "<b>锁定技</b>，当你造成或受到伤害时，你重铸X张牌（不足则全重铸），若你的体力值不大于X (X为此技能发动次数）且"..
  "“<a href='#lb__yingchi_shiwaluo'><font color='red'>史瓦罗</font></a>”存活，"..
  "你替换武将为 “<a href='#lb__yingchi_shiwaluo'><font color='red'>史瓦罗</font></a>”，"..
  "你与“<a href='#lb__yingchi_shiwaluo'><font color='red'>史瓦罗</font></a>”的体力与体力上限独立计算。",

  ["#lb__yingchi_shiwaluo"] = "<b>史瓦罗</b> 4/4 <br>" ..
  "<b>演析</b>：<b>锁定技</b>，你仅可以使用本回合进入弃牌堆中的最大类别的牌且不可被响应。<br>"..
  "<b>誓护</b>：<b>锁定技</b>，每回合限一次，当你造成或受到伤害后，你摸体力值数张牌并使用一张牌，然后若你的手牌数为全场最大，你弃置体力值数张牌，否则你复原所有技能，替换武将为“<a href='#lb__shihu_kelala'><font color='red'>克拉拉</font></a>”。",

  ["#lb__yingchi"] = "影翅：请重铸 %arg 张牌",
  ["#lb__yingchi_ask"] = "影翅：请声明一种颜色，你摸一张牌并展示之，重复此流程直到摸到声明颜色的牌",

  ["$lb__yingchi1"] = "不能再犹豫了。",
  ["$lb__yingchi2"] = "我…我才不怕你们！",
}

local yingchi_spec = {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(skel.name) and target == player and not player:isNude()
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local num = player:usedSkillTimes(skel.name, Player.HistoryGame) + 1
    local cards = player:getCardIds("he")
    if #cards > num then
      cards = room:askToCards(player, {
        min_num = num,
        max_num = num,
        skill_name = skel.name,
        include_equip = true,
        cancelable = false,
        prompt = "#lb__yingchi:::" .. num,
      })
    end
    if #cards > 0 then
      event:setCostData(self, { num = num, cards = cards })
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local cards = event:getCostData(self).cards
    local num = event:getCostData(self).num
    room:recastCard(cards, player, skel.name)
    local list = room:getTag("lb__shihu" .. player.id) or { lb__shiwaluo = { 4, 4 } }
    if (not player.dead) and (player.hp <= num)
        and list.lb__shiwaluo[1] > 0 and list.lb__shiwaluo[2] > 0 then
      list.lb__kelala = { player.hp, player.maxHp }
      room:setTag("lb__shihu" .. player.id, list)
      room:delay(800)
      room:changeHero(player, "lb__shiwaluo", false, player.deputyGeneral == "lb__kelala", true, false)
      player.hp = list.lb__shiwaluo[1]
      player.maxHp = list.lb__shiwaluo[2]
      room:broadcastProperty(player, "maxHp")
      room:broadcastProperty(player, "hp")
      --p(room:getTag("lb__shihu"..player.id))
    end
  end,
}

skel:addEffect(fk.DamageCaused, yingchi_spec)
skel:addEffect(fk.DamageInflicted, yingchi_spec)

return skel
